package com.systemdevelopment.mainproject.Controller;

import com.systemdevelopment.mainproject.Model.*;

import java.sql.SQLException;


public class AdminController extends UserController {

    public AdminController() {

    }

    public AdminController(User u) {
        super(u);
    }


    public int addBook(Book book) {
        try {
            book.InsertIntoWrite();
        } catch (SQLException e) {
            e.printStackTrace();
            return 0;
        }
        return 1;
    }//进书，给Book表加一行，调Book的方法就行


    public boolean addBorrowRecord(BorrowRecord record) {
		BorrowRecord borrowRecord = record.insertRecord();
		return borrowRecord!=null;
    }//添加借阅记录,给LENDING表加一行，调BorrowRecord类里的方法

    public int deleteBook(Book book) throws SQLException {
    	Book.DeleteBookFromDB(book.getName());
        return 0;
    }//删除书，从Book表中删除一行，调用Book的方法。


    public boolean deleteBorrowRecord(BorrowRecord record) {
    	record.deleteBorrowRecord();
        return false;
    }//删除借阅记录，调用BorrowRecord类的方法


    public boolean searchBorrowRecord(BorrowRecord record) {
        return   record.getRecord()!=null;
    }//搜索借阅记录,（为什么参数是借阅记录？），调用BorrowRecord类的方法


    public int updateBook(Book book) {
    	//book.updateBook();
        book.getNowQuantity();
		return 0;
    }//更新书籍信息，更新Book表中的一行，调用Book类的方法。

    public boolean updateBorrowRecord(BorrowRecord record) {
    	return record.updateRecord()!=null;
    }//更新借阅记录，更新Lending表中的一行，调用BorrowRecord类里的方法。

    public void test() {
        System.out.println("AdminController");
    }
}

